import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from  '@/views/Login.vue'
import Home from '@/views/Home.vue'
import SellerListFinish from '@/views/SellerListFinish.vue'
import SellerListWillClass from '@/views/SellerListWillClass.vue'
import SellerListClassFeeLogs from '@/views/SellerListClassFeeLogs.vue'
import SellerListAllStudent from '@/views/SellerListAllStudent.vue'
import UpdatePass from '@/views/UpdatePass.vue'
Vue.use(VueRouter)

const routes = [
  {path:'/',redirect:'/login'},
  {name:'登录',path:'/login',component:Login},

  {name:'销售主页',path:'/home',component:Home,children:[
      {name:'课时完成页面',path:'/sellerListFinish',component:SellerListFinish},
      {name:'课时未完成页面',path:'/sellerListWillClass',component:SellerListWillClass},
      {name:'课程提成明细',path:'/sellerListClassFeeLogs',component:SellerListClassFeeLogs},
      {name:'所有管理的学生',path:'/sellerListAllStudent',component:SellerListAllStudent},
      {name:'修改密码',path:'/updatePass',component:UpdatePass},
    ]},

]


const router = new VueRouter({
  routes
})

router.beforeEach(function (to,from,next) {
    if(to.path=='/login'){
      return next();
    }
    let user=sessionStorage.getItem("seller");
    if(user){
      return next();
    }
    return next('/login');
})
export default router
